﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BootyBay.StoreAppMgmtCore
{
    public class ConsoleSpinner
    {
        int counter;
        public ConsoleSpinner()
        {
            counter = 0;
        }
        private void Turn()
        {
            counter++;
            switch (counter % 4)
            {
                case 0: Console.Write("/"); break;
                case 1: Console.Write("-"); break;
                case 2: Console.Write("\\"); break;
                case 3: Console.Write("|"); break;
            }
            Console.SetCursorPosition(Console.CursorLeft - 1, Console.CursorTop);
        }

        bool turning = false;
        public async void StartTurnAsync()
        {
            if (turning)
                return;

            turning = true;

            while (turning)
                Turn();
        }

        public void StopTurn()
        {
            turning = false;

        }

    //Console.Write("Working....");
    //while (true) 
    //{
    //    spin.Turn();
    //}
    }
}
